Climate reconstruction of the Common Era

Climate stripes (Data: Berkeley Earth)

Climate prediction (reaching 1.5°C and 2°C at the current pace)

---
title: "Global Average Temperature Anomalies"
#author: "Wanda Bodnar"
#date: "20/01/2022"
output:
  flexdashboard::flex_dashboard:
    source_code: embed
    theme:
      version: 4
      primary: "black"
      navbar-bg: "black"
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```




###  Climate reconstruction of the Common Era { .chart-1 }

```{r}

### PAGES2k Global 2,000 Year Multiproxy Database: https://www.ncei.noaa.gov/access/paleo-search/study/21171
### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt

library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)

c <- read.csv("c.csv")

c$Anomaly <- formattable(c$Anomaly, format = "f", digits = 2)

col_strip <- brewer.pal(11, "RdBu")

cc <- ggplot() +
  geom_bar(data = c, show.legend = FALSE, aes(x = Year, y = Anomaly, fill = Anomaly, text = Anomaly), stat = "identity") +
  geom_hline(yintercept = 0, linetype = "dotted", 
             color = "white", size = .5) +
  geom_hline(yintercept = 1, linetype = "dashed", 
             color = "white", size = .3) +
  scale_fill_gradientn(colors = rev(col_strip)) +
  scale_x_continuous(breaks = c(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1712, 1800, 2021)) +
  scale_y_continuous(breaks = c(0, 1)) +
  annotate("text", x = 1712, y = 0.25, colour = "white", label = "Steam engine") +
  annotate("segment", x = c(1712), y = 0.05, xend = c(1712), yend = c(0.2), colour = "white", 
           arrow = arrow(length = unit(2, "mm"), type = "closed")) +
  ylab("Anomaly °C") +
  theme(plot.background = element_rect(fill = "black"),
        panel.background = element_rect(fill = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_text(colour = "white", size = 10),
        axis.text = element_text(colour = "white", size = 10),
        axis.line = element_line(colour = "white"),
        plot.title = element_text(colour = "white", hjust = 0.5),
        plot.subtitle = element_text(colour = "white", hjust = 0.5),
        plot.caption = element_text(colour = "white"))

ggplotly(cc, tooltip = "text")
```


### Climate stripes (Data: Berkeley Earth) { .chart-2 }

```{r}

### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
### Warming stripes: @ Ed Hawkins https://showyourstripes.info/s/globe

library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)

combined <- read.csv("berkeley.csv")

combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)

theme_strip <- theme_minimal()+
  theme(axis.text.y = element_blank(),
        axis.line.y = element_blank(),
        panel.grid.major = element_blank(),
        axis.text.x = element_text(vjust = 3, colour = "white", size = 10),
        panel.grid.minor = element_blank(),
        axis.title = element_blank(),
        plot.background = element_rect(fill = "black"),
        panel.background = element_rect(fill = "black"),
        legend.title = element_text(hjust = 0.5, colour = "white", size = 10),
        legend.text = element_text(colour = "white", size = 10))

col_strip <- brewer.pal(11, "RdBu")

c <- ggplot(combined, aes(x = Year, y = 1, fill = Anomaly)) +
  geom_tile(aes(text = Anomaly)) +
  scale_y_continuous(expand = c(0, 0)) +
  scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920, 
                                1930, 1940, 1950, 1960, 1970, 1980, 1990, 
                                2000, 2010, 2021)) +
  scale_fill_gradientn(name = "Anomaly °C", colors = rev(col_strip)) +
  guides(fill = guide_colorbar(barwidth = 0.5)) +
  theme_strip

ggplotly(c, tooltip = "text")
```


### Climate prediction (reaching 1.5°C and 2°C at the current pace) { .chart-3 }

```{r}

### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
### Climate prediction: https://twitter.com/jrockstrom/status/1482616870394023936

library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)

combined <- read.csv("berkeley.csv")

combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)

col_strip <- brewer.pal(11, "RdBu")

forecast <- read.csv("berkeley_f.csv")

forecast$Anomaly <- formattable(forecast$Anomaly, format = "f", digits = 2)

annotation <- data.frame(
  x = c(2033, 2060),
  y = c(1.6, 2.1),
  label = c("1.5°C", "2°C"))

f <- ggplot() +
  geom_bar(data = combined, show.legend = FALSE, aes(x = Year, y = Anomaly, fill = Anomaly, text = Anomaly), stat = "identity") +
  geom_bar(data = forecast, show.legend = FALSE, aes(x = Year, y = Anomaly, text = Anomaly), fill = c("#520018", "#3d0012"), colour = "black", stat = "identity") +
  geom_hline(yintercept = 0, linetype = "dotted", 
             color = "white", size = .5) +
   geom_hline(yintercept = 1, linetype = "dashed", 
             color = "white", size = .3) +
  geom_hline(yintercept = 1.5, linetype = "dashed", 
             color = "white", size = .3) +
  geom_hline(yintercept = 2, linetype = "dashed", 
             color = "white", size = .3) +
  scale_fill_gradientn(colors = rev(col_strip)) +
  scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920, 
                                1930, 1940, 1950, 1960, 1970, 1980, 1990, 
                                2000, 2010, 2021, 2033, 2060)) +
  scale_y_continuous(breaks = c(0, 1, 1.5, 2)) +
  geom_text(data = annotation, aes(x = x, y = y, label = label),
            color = "white", 
            size = 4, fontface = "bold" ) +
  annotate("text", x = 1995, y = -0.3, colour = "white", label = "COP1") +
  annotate("segment", x = c(1995), y = -0.05, xend = c(1995), yend = c(-0.2), colour = "white", 
           arrow = arrow(length = unit(2, "mm"), type = "closed")) +
  annotate("text", x = 2021, y = -0.3, colour = "white", label = "COP26") +
  annotate("segment", x = c(2021), y = -0.05, xend = c(2021), yend = c(-0.2), colour = "white", 
           arrow = arrow(length = unit(2, "mm"), type = "closed")) +
  ylab("Anomaly °C") +
  theme(plot.background = element_rect(fill = "black"),
        panel.background = element_rect(fill = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_text(colour = "white", size = 10),
        axis.text = element_text(colour = "white", size = 10),
        axis.line = element_line(colour = "white"),
        plot.title = element_text(colour = "white", hjust = 0.5),
        plot.subtitle = element_text(colour = "white", hjust = 0.5),
        plot.caption = element_text(colour = "white"))

ggplotly(f, tooltip = "text")
```